﻿var tmpqqtoken = "1223";
var UC = {
    QQToken: null,
    AuthToken: null,
    Name: null,
    _ucsvr: null,
    isLogin: function () {
        return !!this.AuthToken;
    },
    tryLogin: function (onsucc, onfail) {
        var _t = this;
        this._ucsvr.TryLogin(tmpqqtoken, function (ui) {
            if (ui == null) {
                if (onfail) onfail();
                return;
            }
            _t.AuthToken = ui.Auth;
            _t.Name = ui.User.Name;
            if (onsucc) onsucc(ui);
        }, function (err) {
            if (onfail) onfail(err);
            else alert(err.get_message());
        });
    },
    Reg: function (obj, onsucc, onfail) {
        obj.token = tmpqqtoken;
        var _t = this;
        this._ucsvr.Reg(obj, function (result) {
            _t.AuthToken = result.Auth;
            _t.Name = result.User.Name;
            if (onsucc) onsucc(result);
        }, onfail);
    },
    Union: function (obj) {
        obj.token = tmpqqtoken;
        obj.auth = this.AuthToken;
        return obj;
    }
};
UC._ucsvr = imdoo.svr.vol;